package com.suse.ecommerce.controller;

import com.suse.ecommerce.pojo.Address;
import com.suse.ecommerce.pojo.Shopping;
import com.suse.ecommerce.pojo.User;
import com.suse.ecommerce.service.AddressService;
import com.suse.ecommerce.service.ShoppingService;
import com.suse.ecommerce.uilts.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import java.util.List;

@RequestMapping("/auth")
@RestController
public class ConfirmController {
    @Autowired
    private ShoppingService shoppingService;

    @Autowired
    private AddressService addressService;

    @RequestMapping("/queryShoppingWithConfirm")
    public Msg queryShoppingWithConfirm(@SessionAttribute("user") User user){
        //根据用户ID查询出购物车信息
        List<Shopping> shoppings = shoppingService.queryShopping(user.getUserId());
        //查询用户收货地址
        List<Address> addresses=addressService.queryAllAdress(user.getUserId());
        return  Msg.success("查询成功").add("shoppings",shoppings).add("addresses",addresses);

    }
}
